package org.jeecg.modules.charge.service.impl;

import org.jeecg.entity.charge.ChargeInvoice;
import org.jeecg.entity.charge.ChargeInvoiceInfo;
import org.jeecg.modules.charge.mapper.ChargeInvoiceMapper;
import org.jeecg.modules.charge.service.IChargeInvoiceService;
import org.jeecg.vo.charge.ChargeInvoiceExcel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.jeecg.modules.charge.mapper.ChargeInvoiceInfoMapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 票据
 * @Author: jeecg-boot
 * @Date:   2019-08-08
 * @Version: V1.0
 */
@Service
public class ChargeInvoiceServiceImpl extends ServiceImpl<ChargeInvoiceMapper, ChargeInvoice> implements IChargeInvoiceService {

    @Autowired
    private ChargeInvoiceMapper  chargeInvoiceMapper;

    @Autowired
    private ChargeInvoiceInfoMapper  chargeInvoiceInfoMapper;

    @Override
    public List<ChargeInvoice> getInvoicesByDm(String invoiceDm) {
        List<ChargeInvoice> invoices= chargeInvoiceMapper.getInvoicesByDm(invoiceDm);
        return invoices;
    }

    @Override
    public Integer updateInvoices(ChargeInvoice invoice) {
        return chargeInvoiceMapper.updateInvoices(invoice);
    }

    @Override
    public String getIdByInvoice(String invoiceHm, String invoiceDm) {
        String pjId = chargeInvoiceMapper.getIdByInvoice(invoiceHm,invoiceDm);
        return pjId;
    }
    @Override
    public List<ChargeInvoice> getInvoicesByDmAll(String invoiceDm){
        List<ChargeInvoice> invoices= chargeInvoiceMapper.getInvoicesByDmAll(invoiceDm);
        return invoices;
    }
    //获取票据信息以及票据详细信息
    @Override
    public ChargeInvoice  getInvoiceDmHm(String invoiceHm,String invoiceDm){
        ChargeInvoice invoice =  chargeInvoiceMapper.getInvoiceDmHm(invoiceHm,invoiceDm);
        List<ChargeInvoiceInfo> infolist = chargeInvoiceInfoMapper.getInvoiceInfo(invoice.getId());
        invoice.setInfoList(infolist);
        return invoice;
    }

    @Override
    public List<ChargeInvoice> getInvoicesByDmCharged(String invoiceDm, String endDate){
        List<ChargeInvoice> invoices= chargeInvoiceMapper.getInvoicesByDmCharged(invoiceDm,endDate);
        return invoices;
    }

    public List<ChargeInvoice>  getInvoice(ChargeInvoice invoice){
        List<ChargeInvoice> invoices= chargeInvoiceMapper.getInvoice(invoice);
        return invoices;
    }

    public List<ChargeInvoiceExcel>  getInvoiceExcel(ChargeInvoice invoice){
        List<ChargeInvoiceExcel> invoiceExcels= chargeInvoiceMapper.getInvoiceExcel(invoice);
        return invoiceExcels;
    }

    /**票据作废*/
    public Integer scrap(ChargeInvoice invoice){
        return chargeInvoiceMapper.scrap(invoice);
    }

    /**根据ID查询票据*/
    public ChargeInvoice get(String id){
        return chargeInvoiceMapper.get(id);
    }


}
